#include <iostream>
#include "Commons/option.h"


using namespace Jin;


int main() {

	Config cfg;
	if (cfg.Create(_T("Root"))) {

		printf("cfg.Create() == true\n");

		auto option1 = cfg.AddOption(_T("Option1"));
		option1->SetText("text1");

		auto option2 = option1.AddOption(_T("Option2"));
		option2->SetText("text2");

		if (cfg.Save("test.xml")) {
			printf("cfg.Save() == true\n");
		}
	}

	if (cfg.Open("test.xml")) {
		printf("cfg.Open() == true\n");

		const auto option1 = cfg["Option1"];
		if (option1) {
			printf("option1 text = %s\n", option1->GetText());
			auto option2 = option1["Option2"];
			if (option2) {
				printf("option2 text = %s\n", option2->GetText());
			}
		}
	}

	return 0;
}